package com.xu.tools.config.mq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xuguan
 * @date 2023/4/6
 * @desc rabbit交换机, 队列, 绑定关系配置
 */
@Configuration
public class RabbitConfig {

    @Bean
    public Queue smsQueue() {
        return new Queue("sms.queue", true, false, false);
    }

    @Bean
    public Exchange smsExchange() {
        return new TopicExchange("sms-event-exchange", true, false);
    }

    @Bean
    public Binding smsBinding() {
        return new Binding("sms.queue",
                Binding.DestinationType.QUEUE,
                "sms-event-exchange",
                "sms.send",
                null);
    }
}
